// ignore_for_file: non_constant_identifier_names

import 'dart:convert';

import '../../hj_page/pre_sale/pre_sale_model.dart';
import 'ads_model.dart';
import 'announcement_entity.dart';

class AdvanceStatus {
  bool? gameActivityPopUp;
  bool? activityPopUp; // 预售活动是否首页弹窗
  bool? activityStatus; // 是否开启
  bool? gameActivityStatus;
  bool? balancePayment; //是否有尾款支付
  String? oid;
  PrivilegeLimit? privilegeLimit; //预付权益

  AdvanceStatus.fromJson(dynamic json) {
    activityStatus = json['activityStatus'];
    gameActivityStatus = json['gameActivityStatus'];
    balancePayment = json['balancePayment'];
    gameActivityPopUp = json['gameActivityPopUp'];
    activityPopUp = json['activityPopUp'];
    oid = json['oid'];
    privilegeLimit = json['privilegeLimit'] != null ? PrivilegeLimit.fromJson(json['privilegeLimit']) : null;
  }
}

class PrivilegeLimit {
  bool? hasLimit; //是否有权益限制
  Limit? limit;
  Remain? remain;

  PrivilegeLimit({this.hasLimit, this.limit, this.remain});

  PrivilegeLimit.fromJson(Map<String, dynamic> json) {
    hasLimit = json['hasLimit'];
    limit = json['limit'] != null ? new Limit.fromJson(json['limit']) : null;
    remain = json['remain'] != null ? new Remain.fromJson(json['remain']) : null;
  }
}

class Limit {
  int? aiUndressLimitPerDay; //每日ai脱衣次数限制
  int? coinVideoLimitPerDay; //每日金币视频免费次数
  int? downloadLimitPerDay; //每日下载次数限制
  int? luckyDrawLimitPerDay; //每日抽奖次数限制

  Limit({this.aiUndressLimitPerDay, this.coinVideoLimitPerDay, this.downloadLimitPerDay, this.luckyDrawLimitPerDay});

  Limit.fromJson(Map<String, dynamic> json) {
    aiUndressLimitPerDay = json['aiUndressLimitPerDay'];
    coinVideoLimitPerDay = json['coinVideoLimitPerDay'];
    downloadLimitPerDay = json['downloadLimitPerDay'];
    luckyDrawLimitPerDay = json['luckyDrawLimitPerDay'];
  }
}

class Remain {
  int? todayAiUndressCount; //今日剩余ai脱衣次数
  int? todayCoinVideoCount; //今日剩余金币视频观看次数
  int? todayDownloadCount; //今日剩余下载次数
  int? todayLuckyDrawCount; //今日剩余抽奖次数

  void reduceVideoCoinCount() {
    todayCoinVideoCount = (todayCoinVideoCount ?? 0) - 1;
  }

  Remain({this.todayAiUndressCount, this.todayCoinVideoCount, this.todayDownloadCount, this.todayLuckyDrawCount});

  Remain.fromJson(Map<String, dynamic> json) {
    todayAiUndressCount = json['todayAiUndressCount'];
    todayCoinVideoCount = json['todayCoinVideoCount'];
    todayDownloadCount = json['todayDownloadCount'];
    todayLuckyDrawCount = json['todayLuckyDrawCount'];
  }
}

class BannerJump {
  AdditionalProp? additionalProp;

  BannerJump({this.additionalProp});

  BannerJump.fromJson(Map<String, dynamic> json) {
    additionalProp = json['1'] != null ? new AdditionalProp.fromJson(json['1']) : null;
  }
}

class ProxyBannerJump {
  AdditionalProp? additionalProp;

  ProxyBannerJump({this.additionalProp});

  ProxyBannerJump.fromJson(Map<String, dynamic> json) {
    additionalProp = json['2'] != null ? new AdditionalProp.fromJson(json['2']) : null;
  }
}

class AdditionalProp {
  String? banner; //BANNER图片
  String? endAt; //结束时间
  int? position; //位置 1:视频播放器下方
  String? startAt; //开始时间
  String? title; //标题
  String? url; //跳转地址

  AdditionalProp({this.banner, this.endAt, this.position, this.startAt, this.title, this.url});

  AdditionalProp.fromJson(Map<String, dynamic> json) {
    banner = json['banner'];
    endAt = json['endAt'];
    position = json['position'];
    startAt = json['startAt'];
    title = json['title'];
    url = json['url'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['banner'] = this.banner;
    data['endAt'] = this.endAt;
    data['position'] = this.position;
    data['startAt'] = this.startAt;
    data['title'] = this.title;
    data['url'] = this.url;
    return data;
  }
}

class QuickSearch {
  String? id;
  String? title;
  String? searchKeyword;
  String? videoID;
  String? link;
  bool? enable;
  String? createdAt;
  String? updatedAt;

  QuickSearch({this.id, this.title, this.searchKeyword, this.videoID, this.link, this.enable, this.createdAt, this.updatedAt});

  QuickSearch.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    title = json['title'];
    searchKeyword = json['searchKeyword'];
    videoID = json['videoID'];
    link = json['link'];
    enable = json['enable'];
    createdAt = json['createdAt'];
    updatedAt = json['updatedAt'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['title'] = this.title;
    data['searchKeyword'] = this.searchKeyword;
    data['videoID'] = this.videoID;
    data['link'] = this.link;
    data['enable'] = this.enable;
    data['createdAt'] = this.createdAt;
    data['updatedAt'] = this.updatedAt;
    return data;
  }
}

class UserAward {
  int? number;
  String? desc;
  String? imgUrl;
  UserAward.fromJson(Map<String, dynamic> json) {
    imgUrl = json['imgUrl'];
    desc = json['desc'];
    number = json['number'];
  }
}

class DomainSourceModel {
  AdsBean? ads; //广告
  List<String>? domain; //接口域名
  List<SourceBean>? source;
  List<Sourcelist>? sourceList;
  List<CheckVersionInfo>? ver;
  List<SystemConfig>? systemConfigList;
  int? totalWatch; //非会员每日可观看次数

  String? dataBuriedPoint; //数据埋点
  String? activeUrl; //抽奖链接
  int? adsTimeLongVideo; //长视频广告时间
  List<JGAreaModel>? jgArea; //金刚区配置
  String? aiUndressPrice; //AI脱衣价格
  String? aiChangeFaceImgPrice; //AI脱衣价格

  int? sendMsgPrice;
  AdvanceStatus? advanceStatus;
  AdvancePage? advancePage;
  bool? gameActivityPopUp;
  bool? broadcast; //是否展示直播模块
  List<UserAward>? userAwards; // 用户获得的奖章
  List<String>? aiBubble;

  bool? storeIsOpen; //原味商店开关
  int? backgroundTheme; //背景主题 0：默认主题，1:新春主题
  BannerJump? bannerJump; //限时Banner活动
  ProxyBannerJump? proxyBannerJump;
  String? festivalUi; //节日ui
  String? luckyDrawH5; //抽奖H5链接
  String? luckyDrawIcon; //奖入口浮动图标 图片地址
  List<String>? hotSearchTerms; // 搜索热门词;
  String? darkWebVipId; // 暗网 vip卡id
  String? darkWebVipName; //  暗网 vip卡名
  List<String>? recommendVipIds;
  static DomainSourceModel fromJson(Map<String, dynamic>? map) {
    map ??= {};
    DomainSourceModel info = DomainSourceModel();
    if(map['recommendVipIds'] is List) {
      info.recommendVipIds = (map['recommendVipIds'] as List).map((e) => e.toString()).toList();
    }
    info.darkWebVipId = map['darkWebVipId'];
    info.darkWebVipName = map['darkWebVipName'];
    info.backgroundTheme = map['backgroundTheme'];
    if (map.containsKey('advancePage')) {
      info.advancePage = AdvancePage.fromJson(map['advancePage']);
    }
    info.aiBubble = (map['aiBubble'] as List?)?.map((e) => e.toString()).toList();

    if (map.containsKey('advanceStatus')) {
      info.advanceStatus = AdvanceStatus.fromJson(map['advanceStatus']);
    }

    if (map.containsKey('gameActivityPopUp')) {
      info.gameActivityPopUp = map['gameActivityPopUp'];
    }

    if (map.containsKey('ads')) {
      info.ads = AdsBean.fromMap(map['ads']);
    }
    if (map.containsKey('domain')) {
      info.domain = (map['domain'] as List?)?.map((o) => o.toString()).toList();
    }
    if (map.containsKey('source')) {
      info.source = (map['source'] as List?)?.map((o) => SourceBean.fromMap(o)).toList();
    }

    if (map.containsKey('sourceList')) {
      info.sourceList = (map['sourceList'] as List?)?.map((o) => Sourcelist.fromJson(o)).toList();
    }

    if (map.containsKey('ver')) {
      info.ver = (map['ver'] as List?)?.map((o) => CheckVersionInfo.fromMap(o)).toList();
    }
    if (map.containsKey('systemConfigList')) {
      info.systemConfigList = (map['systemConfigList'] as List?)?.map((o) => SystemConfig.fromJson(o)).toList();
    }

    info.totalWatch = map['totalWatch'];
    info.dataBuriedPoint = map['dataBuriedPoint'];
    info.activeUrl = map['luckyDrawH5'];
    info.adsTimeLongVideo = map['adsTimeLongVideo'];
    info.aiUndressPrice = map['aiUndressPrice']?.toString();
    info.aiChangeFaceImgPrice = map['aiChangeFaceImgPrice']?.toString();
    info.userAwards = (map['userAwards'] as List?)?.map((e) => UserAward.fromJson(e)).toList();
    if (map['jgArea'] is List) {
      info.jgArea = (map['jgArea'] as List?)?.map((e) => JGAreaModel.fromJson(e)).toList();
    }

    info.sendMsgPrice = map['sendMsgPrice'];
    info.broadcast = map['broadcast'] == null ? false : map['broadcast'];
    info.storeIsOpen = map['storeIsOpen'];
    info.bannerJump = map['bannerJump'] != null ? BannerJump.fromJson(map['bannerJump']) : null;
    info.proxyBannerJump = map['bannerJump'] != null ? ProxyBannerJump.fromJson(map['bannerJump']) : null;
    info.festivalUi = map['festivalUi'];
    if (info.festivalUi == null || info.festivalUi?.isEmpty == true) {
      info.festivalUi = '默认';
    }
    info.luckyDrawH5 = map['luckyDrawH5'];
    info.luckyDrawIcon = map['luckyDrawIcon'];
    if (map['hotSearchTerms'] is List) {
      info.hotSearchTerms = (map['hotSearchTerms'] as List).map((e) => e.toString()).toList();
    }
    return info;
  }
}

class SourceBean {
  String? id;
  String? domain;
  bool? isActive;
  String? type;

  static SourceBean fromMap(Map<String, dynamic>? map) {
    map ??= {};
    SourceBean sourceBean = SourceBean();
    sourceBean.id = map['id'];
    sourceBean.domain = map['domain'];
    sourceBean.isActive = map['isActive'];
    sourceBean.type = map['type'];
    return sourceBean;
  }
}

class MarqueeModel {
  String? content; //跑马灯内容
  String? url; //跳转连接
  bool? active; //激活状态
  String? id; //公告id
  int? type; //跑马灯类型，0，会员中心；
  int? position;
  String? positionDesc;

  static MarqueeModel fromMap(Map<String, dynamic>? map) {
    map ??= {};
    MarqueeModel model = MarqueeModel();
    model.content = map['content'];
    model.url = map['url'];
    model.active = map['model'];
    model.id = map['id'];
    model.type = map['type'];
    model.position = map['position'];
    model.positionDesc = map['positionDesc'];
    return model;
  }
}

class CheckVersionInfo {
  String? description;
  bool? forcedUpdate;
  String? platform;
  String? url;
  String? verName;
  int? code;

  static CheckVersionInfo fromMap(Map<String, dynamic>? map) {
    map ??= {};

    CheckVersionInfo info = CheckVersionInfo();
    info.description = map['description'];
    info.forcedUpdate = map['forcedUpdate'];
    info.platform = map['platform'];
    info.url = map['url'];
    info.verName = map['verName'];
    info.code = map['Code'];
    return info;
  }

  static List<CheckVersionInfo> toList(List<dynamic> mapList) {
    List<CheckVersionInfo> list = [];

    Iterator iterator = mapList.iterator;
    while (iterator.moveNext()) {
      Map<String, dynamic> current = iterator.current;
      list.add(fromMap(current));
    }
    return list;
  }

  Map toJson() => {
        "description": description,
        "forcedUpdate": forcedUpdate,
        "platform": platform,
        "url": url,
        "verName": verName,
        "Code": code,
      };
}

class AdsBean {
  List<AdsInfoModel>? adsInfoList;

  // 文本公告
  List<AnnounceInfoBean>? announInfo;

  ///多个公告
  List<AnnounceInfoBean>? announList;

  static AdsBean fromMap(Map<String, dynamic>? map) {
    map ??= {};

    AdsBean info = AdsBean();
    info.announInfo = (map['announInfo'] as List?)?.map((o) => AnnounceInfoBean.fromJson(o)).toList();
    info.announList = (map['announList'] as List?)?.map((o) => AnnounceInfoBean.fromJson(o)).toList();
    info.adsInfoList = (map['adsInfoList'] as List?)?.map((o) => AdsInfoModel.fromMap(o)).toList();
    return info;
  }

  Map toJson() => {
        "announInfo": announInfo,
      };
}

class AnnounceInfoBean {
  String? content;
  String? cover;
  String? href; //图片公告点击时跳转的地址
  int? type; //0:系统公告 1：图片公告,3,活动公告
  String? title;

  static AnnounceInfoBean fromJson(Map<String, dynamic>? map) {
    map ??= {};

    AnnounceInfoBean info = AnnounceInfoBean();
    info.content = map['content'];
    info.cover = map['cover'];
    info.href = map['href'];
    info.type = map['type'];
    info.title = map['title'];
    return info;
  }

  Map toJson() => {
        "content": content,
        "cover": cover,
        "href": href,
        "type": type,
        "title": title,
      };
}

JingangArea jingangAreaFromJson(String? str) => JingangArea.fromJson(json.decode(str ?? ""));

String? jingangAreaToJson(JingangArea data) => json.encode(data.toJson());

class JingangArea {
  JingangArea({
    this.list,
  });

  List<JGAreaModel>? list;

  factory JingangArea.fromJson(Map<String, dynamic> json) => JingangArea(
        list: json["list"] == null ? [] : List<JGAreaModel>.from(json["list"].map((x) => JGAreaModel.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "list": List<dynamic>.from((list ?? []).map((x) => x.toJson())),
      };
}

class JGAreaModel {
  JGAreaModel({
    this.id,
    this.name,
    this.img,
    this.desc,
    this.linkType,
    this.linkUrl,
    this.type,
    this.mid,
  });

  String? id;
  String? name;
  int? type;
  String? img;
  String? desc;
  int? linkType;
  String? linkUrl;
  String? mid;
  factory JGAreaModel.fromJson(Map<String, dynamic> json) => JGAreaModel(
        id: json["id"],
        name: json["name"],
        img: json["img"],
        desc: json["desc"],
        linkType: json["link_type"],
        linkUrl: json["link_url"],
        type: json["type"],
        mid: json["mid"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "img": img,
        "desc": desc,
        "link_type": linkType,
        "link_url": linkUrl,
        'mid':mid,
      };
}

List<Sourcelist> sourcelistFromJson(String str) => List<Sourcelist>.from(json.decode(str).map((x) => Sourcelist.fromJson(x)));

String sourcelistToJson(List<Sourcelist> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class Sourcelist {
  String? id;
  List<Domain>? domain;
  bool? isActive;
  String? type;

  Sourcelist({
    this.id,
    this.domain,
    this.isActive,
    this.type,
  });

  factory Sourcelist.fromJson(Map<String, dynamic> json) => Sourcelist(
        id: json["id"],
        domain: List<Domain>.from(json["domain"].map((x) => Domain.fromJson(x))),
        isActive: json["isActive"],
        type: json["type"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "domain": List<dynamic>.from(domain!.map((x) => x.toJson())),
        "isActive": isActive,
        "type": type,
      };
}

class Domain {
  int? weight;
  String? url;
  String? desc;
  int? status;

  Domain({
    this.weight,
    this.url,
    this.desc,
    this.status,
  });

  factory Domain.fromJson(Map<String, dynamic> json) => Domain(
        weight: json["weight"],
        url: json["url"],
        desc: json["desc"],
        status: json["status"],
      );

  Map<String, dynamic> toJson() => {
        "weight": weight,
        "url": url,
        "desc": desc,
        "status": status,
      };
}
